package com.briup.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class Hello {
    @GetMapping("/jj")
    public String hello() {
        return "有时候感觉自己是一条酸菜鱼，又酸又菜又多余";
    }

    @PostMapping("/kk")
    public String test() {
        return "世上无难事，邓双燕太憨";
    }

    @PostMapping("/11")
    public Wife jxlg() {
        Wife wife = new Wife(1, "lisa", 5800);
        return wife;
    }

    @GetMapping("/mm")
    public List<Wife> wives() {
        Wife wife = new Wife(1, "Jane", 5000);
        Wife wife1 = new Wife(2, "Lisa", 6000);
        List<Wife> list = new ArrayList<>();
        list.add(wife);
        list.add(wife1);
        return list;
    }

    @GetMapping("person")
    public Person person() {
        Person person = new Person(1, "kk", new Wife(1, "lisa", 50000));
        return person;
    }

    @PostMapping("/teacher")
    public Teacher teacher() {
        Teacher teacher = new Teacher();
        teacher.setId(1);
        teacher.setName("Jane");
        List<Wife> list = new ArrayList<>();
        list.add(new Wife(1, "Lisa", 5000));
        list.add(new Wife(2, "Amy", 4000));
        teacher.setWives(list);
        return teacher;
    }

    @PostMapping("/teachers")
    public List<Teacher> teachers() {
        Teacher teacher = new Teacher();
        Teacher teacher1 = new Teacher();

        teacher.setId(1);
        teacher.setName("Jane");
        List<Wife> wives = new ArrayList<>();
        wives.add(new Wife(1, "lisi", 5000));
        wives.add(new Wife(2, "zhangsan", 4000));
        teacher.setWives(wives);

        teacher1.setId(2);
        teacher1.setName("Lisa");
        List<Wife> wives1 = new ArrayList<>();
        wives1.add(new Wife(3, "wangwu", 6000));
        wives1.add(new Wife(4, "lihua", 7000));
        teacher1.setWives(wives1);

        List<Teacher> teachers = new ArrayList<>();
        teachers.add(teacher);
        teachers.add(teacher1);
        return teachers;

    }

    @PostMapping("/list")
    public List list() {
        List list = new ArrayList();
        list.add("jjj");
        list.add("hskdhfids");
        return list;
    }

    @PostMapping("/revice")
    public String revice(String name, int age) {
        System.out.println(name + "--->" + age);
        return "数据已经收到";
    }

    @GetMapping("/data")
    public String data(Student student) {
        System.out.println(student);
        return "数据已经收到";
    }


    @PostMapping("/asd")
    public String asd(@RequestBody Student student){
        System.out.println(student);
        return "数据已经收到";
    }

    @PostMapping("/findAll")
    public List<Student> findAll(int id){
        System.out.println("接受数据为："+id);
        List<Student> students=new ArrayList<>();
        students.add(new Student(1,"Lisa","lady",150));
        students.add(new Student(2,"Jane","girl",200));
        students.add(new Student(3,"Jack","boy",500));
        return students;
    }
}
